package com.kaily.timemanager.view;


import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;

import com.app.common.view.flowlayout.FlowLayout;
import com.kaily.timemanager.obj.TaskClass;

import java.util.List;

/**
 * Created by zhoulikai on 17/3/6.
 * 任务类别流式布局
 */

public class TaskClassFlowLayout extends FlowLayout<TaskClass> {
    public TaskClassFlowLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    private ITaskClassActionListener taskClassActionListener;

    public void setTaskClassActionListener(ITaskClassActionListener taskClassActionListener) {
        this.taskClassActionListener = taskClassActionListener;
    }

    @Override
    protected void onClick(View view, TaskClass taskClass) {
        if (taskClass != null) {

        } else {

        }

    }

    @Override
    protected boolean onLongClick(View view, TaskClass taskClass) {
        return false;
    }


    public TaskClassFlowLayout(Context context) {
        super(context);
    }

    public TaskClassFlowLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    private void init(List<TaskClass> taskClasses) {
        if (taskClasses != null && !taskClasses.isEmpty()) {
            for (int i = 0; i < taskClasses.size(); i++) {
                TaskClass taskClass = taskClasses.get(i);
                if (taskClass != null) {
                    Button btn = new Button(this.getContext());
                    btn.setText(taskClass.getTaskClassName());
                    this.addSubView(btn, taskClass);

                }

            }
        }
    }
}
